<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>心理咨询预约系统</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="__USER__/js/layui/layui.js"></script>
    <link rel="stylesheet" href="__USER__/js/layui/css/layui.css">
    <link rel="stylesheet" href="__USER__/css/base.css">
    <link rel="stylesheet" href="__USER__/css/page/head.css">
    <link rel="stylesheet" href="__USER__/css/page/foot.css">
    <link rel="stylesheet" href="__USER__/css/page/index.css">
</head>


<body>
<div class="head-box">
    <div class="head-tit layui-row">
        <div class="headTit-inner layui-col-md-offset2 layui-col-md8">
            <div class="fl headTit-left">
                <div class="logo fl" style="margin-left: -40%">
                    <img src="__USER__/img/logo.png">
                </div>
                <div class="tit-txt fl" style="margin-left: -25%">
                    <div class="head-tit-bg"><a href="index.html">预约咨询服务平台</a></div>
                    <div class="head-tit-sm">预约诊疗服务平台</div>
                </div>
            </div>
            <div class="fr headTit-right layui-row" style="width: 500px">
                <ul>
                    <li class="layui-nav-item" style="margin-left:95%;margin-top:2%;width: 700px">
                        <a href="../student/info.html"><span style="font-size: 14px; color: #010101">欢迎,   </span><span
                                style="font-size: 20px; color: #0f6bed">   {$Request.session.studentname}   </span> </a>
                        <a style="text-decoration: none" href="javascript:void(0);" onclick="message()"><i
                                class="layui-icon layui-icon-notice"
                                title="消息"><span style="font-size: 14px; color: #2BC807">({$xcount})</span></i></a>

                        <a href="../student/logout"> <span style="font-size: 14px; color: #010101">    ,   退出</span></a>
                    </li>
                </ul>
                <div class="layui-row">

                </div>
            </div>
        </div>
    </div>

    <div class="head-tab layui-row">
        <div class="headTab-inner layui-col-md-offset2 layui-col-md8">
            <ul class="headTab-ul">
                <li>
                    <a href="order.html">预约咨询</a>
                </li>
                <li>
                    <a href="info.html">个人中心</a>
                </li>
                <li>
                    <a href="myorder.html">我的预约</a>
                </li>
                <li>
                    <a href="know.html">了解教师</a>
                </li>
                <li>
                    <a href="message.html">留言建议</a>
                </li>
            </ul>
        </div>
    </div>
</div>

<hr class="hr20">


<!--<img src="__USER__/images/sx.jpg" style="margin-left: 350px">-->
<div style="margin-left: 150px;width: 1px;height: 500px; background: black;"></div>
<div style="margin-left: 70px;margin-top:-450px;font-size: 20px"><a
        href="myorder.html"><span style="color: rgba(55,148,222,0.68)">进行中</span></a>
</div>
<div style="margin-left: 70px;margin-top:350px;font-size: 20px"><a href="complete.html">
    <span style="color: rgba(55,148,222,0.68)">已完成</span></a>
</div>


<div class="layui-form" style="font-size: 15px">
    <p style="font-family: 楷体;font-size: 25px;margin-left: 42%;margin-top: -450px">当前有（<span
            style="color: rgba(15,112,255,0.68)">{$count}</span>）条 <b>已完成</b> 的预约</p>

    <div style="margin-left: 15%">
        <div class="layui-inline">
            <table id="test" lay-filter="test" lay-data="{id: 'test'}"
                   style="border:1px solid black;margin: 0 auto;"></table>
        </div>
    </div>


</div>

<div class="layui-row">
    <div>
        <div class="cardTit">
            <!-- <span class="cardTit-tit">友情链接</span> -->
        </div>
        <div class="body-card">
            <div id="linkurl" class="link-box">
            </div>
        </div>
    </div>

    <div class="layui-col-md12 foot-about">
        <div class="about-box">
            <div><a href="aboutUs.html">关于我们</a></div>
            <span>|</span>
            <div><a href="yinsi.html">隐私条款</a></div>
            <span>|</span>
            <div><a href="contactUs.html">联系我们</a></div>
            <div class="clear"></div>
        </div>
        <div>Copyright © 2019 - 2025 WEDOCTOR. All Rights Reserved. 苏孙举 版权所有</div>
    </div>
</div>

<!--//操作栏-->
<script type="text/html" id="barDemo">
    <a style=" text-decoration: none"><i class="layui-icon layui-icon-delete" lay-event="del" title="删除"></i> </a>
</script>

<script>

    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        var flag = 0;

        //检查设置默认图片
        $(document).ready(function () {

            //消息检测
            if (flag == 0) {
                $.ajax({
                    type: "get",
                    url: "{:url('Student/checkmessage')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        if (data != 0) {
                            layer.msg("您有（" + data + "）条新信息，请注意查看！");
                            flag = 1;
                        }
                    }
                });
            }
        });
    });

    //显示消息
    function message() {
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            shade: 0.7,
            area: ['809px', '500px'],
            content: ['notify'],
            end: function () {
                $.ajax({
                    type: "get",
                    url: "{:url('Student/changenotify')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        //考虑读完之后数字为0
                    }
                });
            }
        });
    }

    layui.use('table', function () {
        var table = layui.table;
        table.render({
            // even: false //开启隔行背景
            // , size: 'sm' //小尺寸的表格
            // , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            minheight: "500px"
            , elem: '#test'
            , page: true
            , id: 'searchreload'
            , limit: 5
            , height: 450
            , width: 1200
            , url: "{:url('Student/completejson')}"
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": "刷新页面试试", //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.data//解析数据列表
                };

            },
            cols: [[
                {field: 'id', title: '预约编号', width: 163}
                , {field: 'sname', title: '学生姓名', width: 200}
                , {field: 'time', title: '预约时间', width: 260, sort: true}
                , {field: 'address', title: '预约地点', width: 220}
                , {field: 'ename', title: '教师姓名', width: 200}
                // , {field: 'time', title: '预约时间', width: 80, sort: true}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
            ]],

        });


        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('真的删除该条预约记录吗？', function (index) {
                    layer.close(index);
                    $.ajax({
                        type: "post",
                        url: "{:url('Student/completedel')}",
                        dataType: "json",
                        data: {"id": data.id},
                        async: false,
                        success: function (data) {
                            console.log(data);
                            if (data.data == 1) {
                                layer.msg("删除成功!", {icon: 1, time: 1000}, function () {
                                    setTimeout('', 100);
                                });
                                table.reload('searchreload');
                            } else {
                                layer.msg("删除失败!", {icon: 2, time: 1000}, function () {
                                    setTimeout('', 100);
                                });
                                table.reload('searchreload');
                            }
                        }
                    });
                });
            }
        })
    });
</script>
</body>
</html>